import request from '@/utils/request'

/**
 * 获取员工简单列表
 * @returns
 */
export const getEmployeesSimpleList = () => {
  return request({
    url: '/sys/user/simple'
  })
}

/**
 * 获取员工列表
 * @param {*} params
 * @returns
 */
export const getEmployeesList = params => {
  return request({
    url: '/sys/user',
    params
  })
}

/**
 * 新增员工
 * @param {*} data
 * @returns
 */
export const addEmployees = data => {
  return request({
    url: '/sys/user',
    method: 'POST',
    data
  })
}

/**
 * 删除员工接口
 * ****/

export function delEmployee(id) {
  return request({
    url: `/sys/user/${id}`,
    method: 'delete'
  })
}

export function importEmployee(data) {
  return request({
    url: '/sys/user/batch',
    method: 'POST',
    data
  })
}

/**
 * 获取员工信息
 * @param {*} id
 * @returns
 */
export function getEmployeeInfo(id) {
  return request({
    url: '/sys/user/' + id,
    method: 'GET'
  })
}

/**
 * 更新信息
 * @param {*} id
 * @returns
 */
export function uploadEmployeeInfo(data) {
  return request({
    url: '/sys/user/' + data.id,
    method: 'PUT',
    data
  })
}

/**
 * 获取员工详细信息
 * @param {*} id 员工id
 * @returns
 */
export function getEmployeeDetail(id) {
  return request({
    url: '/employees/' + id + '/personalInfo',
    method: 'GET'
  })
}

/**
 * 更新员工详细信息
 * @param {*} data {}
 * @returns
 */
export function updateEmployeeDetail(data) {
  return request({
    url: '/employees/' + data.id + '/personalInfo',
    method: 'PUT',
    data
  })
}

/**
 * 获取岗位信息
 * @param {*} id
 * @returns
 */
export function getEmployeeJobInfo(id) {
  return request({
    url: '/employees/' + id + '/jobs',
    method: 'GET'
  })
}

/**
 * 更新岗位信息
 * @param {*} data
 * @returns
 */
export function updateEmployeeJobInfo(data) {
  return request({
    url: '/employees/' + data.id + '/jobs',
    method: 'PUT',
    data
  })
}

/**
 *  更新员工角色
 * @param {*} data { id roleIds }
 * @returns
 */
export function updateEmployeeRoles(data) {
  return request({
    url: 'sys/user/assignRoles',
    method: 'PUT',
    data
  })
}
